package com.ftwj.controller;

import com.ftwj.config.resp.ResultMessage;
import com.ftwj.entity.SysMenu;
import com.ftwj.service.MenuOperationService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
@Slf4j
@RequestMapping("/menu-operation")
public class MenuOperationController {

    @Autowired
    private MenuOperationService menuOperationService;

    @PutMapping("/Menu0peration-Update")
    public ResultMessage updateMenu(@RequestBody SysMenu sysMenu) {
        int rows = menuOperationService.updateMenu(sysMenu);
        return rows > 0 ?ResultMessage.success() : ResultMessage.error();

    }

    @DeleteMapping("/delete/{id}")
    public ResultMessage deleteMenu(@PathVariable("id") String id){
        int flag = menuOperationService.deleteMenu(id);
        return flag> 0 ? ResultMessage.success() : ResultMessage.error();
    }

    @PostMapping("/Menu0peration-Insert")
    public ResultMessage insertMenu(@RequestBody SysMenu sysMenu) {
        int rows = menuOperationService.insertMenu(sysMenu);
        return rows> 0 ? ResultMessage.success() : ResultMessage.error();
    }

}
